package com.example.shortmessage.utils;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

public class ActivityCollectorUtils {

    public static List<Activity> activities = new ArrayList<Activity>();

    //添加活动
    public static void addActivity(Activity activity) {
        if (!activities.contains(activity)) {
            activities.add(activity);
        }
    }

    //移除活动
    public static void removeActivity(Activity activity) {
        activities.remove(activity);
    }

    //关闭所有活动
    public static void finishAll() {
        for (Activity activity : activities) {
            if (!activity.isFinishing()) {
                activity.finish();
            }
        }
    }
}
